package com.loveazure.ui.action;

import java.awt.event.ActionEvent;

import javax.swing.JOptionPane;

import com.loveazure.eo.UserCourse;
import com.loveazure.ui.ConfigPanel;
import com.loveazure.util.FileUtil;

public class ShuffleAction extends ConfigPanelAction {

	private static final String SHUFFLE = "打乱顺序";

	public ShuffleAction(ConfigPanel panel) {
		super(panel, SHUFFLE);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		UserCourse course;
		String path;

		if (panel.table.getSelectedRow() != -1) {
			course = panel.model.getRow(panel.table.getSelectedRow());
			path = "user//" + course.getUser().getName() + "//"
					+ course.getCourse().getFileName();
			if (FileUtil.shuffle(path)) {
				JOptionPane.showMessageDialog(panel, "已打乱顺序");
			}

		}
	}

}
